
<html><head>
<title>leadzero - flibs</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.toc,UL.toc UL, UL.toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.section, LI.subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.requirements LI, UL.syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<! -- Generated from file 'computing/leadzero.man' by tcllib/doctools with format 'html'
   -->
<! -- Copyright &copy; 2012 John Harper
   -->
<! -- CVS: $Id: leadzero.html,v 1.3 2013/05/13 08:03:15 knystrom Exp $ leadzero.n
   -->
<body><div class="doctools">
<h1 class="title">leadzero(n) 1.0  &quot;flibs&quot;</h1>
<div id="name" class="section"><h2><a name="name">Name</a></h2>
<p>leadzero - Flexible F0 format</p>
</div>
<div id="toc" class="section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="toc">
<li class="section"><a href="#toc">Table Of Contents</a></li>
<li class="section"><a href="#synopsis">Synopsis</a></li>
<li class="section"><a href="#section1">Description</a></li>
<li class="section"><a href="#section2">USAGE</a></li>
<li class="section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="synopsis">
<ul class="syntax">
<li><a href="#1"><b class="cmd">string = f0( x, n, s)</b></a></li>
<li><a href="#2"><b class="cmd">integer, parameter :: p1</b></a></li>
<li><a href="#3"><b class="cmd">integer, parameter :: p2</b></a></li>
<li><a href="#4"><b class="cmd">integer, parameter :: ispace</b></a></li>
<li><a href="#5"><b class="cmd">integer, parameter :: rspace</b></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p>Simulate the F0 format with more options, for compilers that implement NaN, Inf.
(f0withIEEE.f90) and for compilers that do not implement these non-normal numbers
(f0noIEEE.f90). Both versions define a Fortran 95/2003 module <em>leadzero</em> and
have a corresponding test program in this file. The code was developed by
J F Harper, Mathematics, Victoria University, Wellington, NZ 20 Jan 2012.</p>
<p>Compilers vary in their own treatments of leading zero and optional + sign
because Fortran standards f90,f95,f2003 differ, and f95 was ambiguous. The
module lets users choose their own treatment. The test program assumes
that NAN and INF are valid inputs to a READ statement for a real variable,
as f2003 requires for processors that support IEEE 754 features. If your
processor does not support them, use f0noIEEE.f90 instead of this
program. The modules in f0noIEEE.f90 and fotest.f90 are identical but
their test programs differ. IEEE intrinsic modules are not used.</p>
</div>
<div id="section2" class="section"><h2><a name="section2">USAGE</a></h2>
<p>The module contains one public function and four public parameters to
aid in their usage:</p>
<dl class="definitions">
<dt><a name="1"><b class="cmd">string = f0( x, n, s)</b></a></dt>
<dd><p>Function f0(x,n,s) or f0(x,n) (the <em>s</em> argument is optional)
returns the shortest possible string of characters containing x in F0.n format,
with leading zero and + sign controlled by the character string s if it is
present, or by SS,F0.n format as in f2003 if not, so if the processor supports
separate positive and negative zeros then f0(-0.0,n) shall begin with
a - sign.</p>
<p>It returns a string of the minimum required length, which is at most <em>rspace+n</em>.</p>
<dl class="arguments">
<dt>real(p1/p2) <i class="arg">x</i></dt>
<dd><p>Value to be written by f0</p></dd>
<dt>integer <i class="arg">n</i></dt>
<dd><p>Number of digits to be written after the decimal point</p></dd>
<dt>character(*) <i class="arg">s</i></dt>
<dd><p>Specifying treatment of + sign and leading zero</p>
<p>If s is absent or contains neither LZ nor SP the effect is that of format
SS,F0.n as in the f2003 standard. If s contains SP the effect is that of
SP,F0.n, i.e. a + sign if x&gt;0 or x is +0.0, a - sign if x&lt;0 or -0.0.
If the processor does not support separate -0.0 and +0.0 then 0.0 is
treated as +0.0. A zero before the decimal point is inserted if the output
would otherwise have had no digits at all, or if s contains LZ and there
would otherwise be no digits before the decimal point. If x is infinite or
not a number, f0 returns the appropriate one of +Inf,Inf,-Inf,NaN.</p></dd>
</dl></dd>
<dt><a name="2"><b class="cmd">integer, parameter :: p1</b></a></dt>
<dd><p>Kind for single-precision reals - p1 = kind(1.0).</p></dd>
<dt><a name="3"><b class="cmd">integer, parameter :: p2</b></a></dt>
<dd><p>Kind for double-precision reals - p2 = kind(1d0).</p></dd>
<dt><a name="4"><b class="cmd">integer, parameter :: ispace</b></a></dt>
<dd><p>The integer parameter <em>ispace</em> is the space needed for -huge(1) in I0 format</p></dd>
<dt><a name="5"><b class="cmd">integer, parameter :: rspace</b></a></dt>
<dd><p>The integer parameter <em>rspace</em> is the space needed for -huge(1d0) in F0.0 format,</p></dd>
</dl>
</div>
<div id="copyright" class="section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2012 John Harper</p>
</div>
</div></body></html>